<template>
    <div>
        123
        <hr>
        <button @click="handleClick">Hello Click me</button>
    </div>
</template>

<script>

import axios from 'axios';

export default {
    data() {
        return {

        };
    },
    components: {

    },
    created() {
        axios.defaults.baseURL = 'http://localhost:8080',
            // 添加请求拦截器
            axios.interceptors.request.use(function (config) {
                console.log("2，请求拦截器");
                
                // 在发送请求之前做些什么
                return config;
            }, function (error) {
                // 对请求错误做些什么
                return Promise.reject(error);
            }); 


        // const instance = axios.create({
        //     baseURL: 'http://localhost:8080'',
        //     timeout: 1000,
        //     headers: { 'Token': 'foobar' }
        // });
    },
    mounted() {

    },
    methods: {
        handleClick() {
            console.log("1，开始");
            
            axios.get('/hello1')
                .then(response => {
                    console.log("3，结束");
                    console.log(response);
                    console.log(response.data);
                    this.message = response.data.message;
                })
                .catch(error => {
                    console.log(error);
                });
        }
    },
};
</script>

<style></style>